Copyright: © Lenham Computer Services Ltd


RASDial Component for Delphi
RASDial Component for Delphi V1.0

Properties	 Methods	 Events	Registration

Unit

RASDial

Description

The RASDial component for Delphi allows the simple programing of the windows Remote Access Service ( RAS ) to provide dialup services for WFWG311 clients. This component requires that you have WFWG311 Remote Access installed on your computer.

The simplest way use the component is to set the BookEntry property to the Name of an Entry in your default RAS phonebook. This can be selected with the drop down list in the object inspector, set the component active using the Active property and then use the Dial Method. When the call is finished or to abort the connection use the Hangup method.

The OnStateChanged Event is generated giving the current state of the outbound connection and any errors that may be occuring on the connection

The Dialling does not have to be done from the RAS phone book. All dialing parameters can be overridden. Just set the PhoneNumber property and if required the CallBack number with the CallBackNumber Property and then use the Dial method.


BookEntry Property

Property BookEntry: string;

Description

Setting the BookEntry property uses the information stored in the passed entry name for its dial parameters. This name must be in the RAS phonebook specified by the Phonebook property.

Comments

The drop down list in the object inspector shows the entries in the default phonebook only.


Dial Method

function Dial: Longint;

Description

The Dial method initiates a Remote Access connection.  The BookEntry, CallbackNumber, PhoneNumber properties set the calling parameters and the Userid, Password, and DomanName properties specify the user authentication settings for the Remote Access Server. This routine will generate a ERASDialNotActive exception if the component is not active.

Returns

If the function is successful then the return value is RAS_SUCCESS.  If the function fails then it returns a non-zero value, which can be evaluated with the GetErrorDesc method

Example

procedure DialoutRAS

var

Err: Longint;

begin

RASDial1.BookEntry := 'Dialout1';

Err := RASDial1.Dial;

if Err <> RAS_SUCCESS Then

begin

MessageDlg(RASDial1.GetErrorDesc(Err),mtError,[mbOK],0);

end;

end;


Hangup Method

function Hangup: Longint;

Description

The Hangup method terminates a Remote Access connection.  This routine generates an ERASDialNotActive exception if the component is not active when this method is called.

Returns

The return value is RAS_SUCCESS if the function is successful. If the function fails the return value is a non-zero error code for use in the GetErrorDesc method


PhoneNumber Property

Property PhoneNumber: string;

Description

The PhoneNumber property specifies the Phone number to be dialled.  A blank value indicates that the BookEntry value is to be used. if BookEntry value is blank then the PhoneNumber property should have a valid phone number.


CallbackNumber Property

Property CallbackNumber: string;

Description

The CallbackNumber property allows the call back number to be specified.  Leaving this property blank specifies that no callback will be used.  Setting this number overrides the callback number in the phonebook entry, set with the BookEntry property.  To use the phonebook entry callback number set the value to asterisk ( * ).  The user must have the Callback privilege set on the remote server that they are connecting to.


Registration

To register the component mail Compuserve [ 72773,2106 ] or 72773.2106@compuserve.com quoting the component name and how we can contact you.

The cost for the component for UK users is GBP 35.00 + VAT(17.5%) and for overseas users USD 50.00.  Educational, sitewide, and source code licenses are also available.

A Compuserve shareware registration ID will be available for VISA/MASTERCARD payments.  Registration gives a license for royalty free distribution of the component in your applications and removes the popup dialog on component load.

The Information and code provided herewith (collectively referred to as "SOFTWARE") is provided as is without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchanantability and fitness for a particular purpose. In no event shall Lenham Computer Services Ltd be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Lenham Computer Services Ltd have been advised of the possibility of such damages.

Lenham Computer Services Limited

9 High Street

Lenham

Kent

ME17 2QD

England.

CompuServe ID [72773,2016] or 72773.2016@compuserve.com


Properties

 = Readonly

Active

BookEntry

CallBackNumber

 ConnState

 DeviceName

 DeviceType

DomainName

Password

PhoneBook

PhoneNumber

Userid


Methods

Dial

GetBookEntries

GetCurrentConnections

GetDeviceInfo

GetErrorDesc

Hangup

InUse


Events

OnConnected

OnDisconnect

OnStateChange


Active Property

property Active: Boolean;

Description

The Active property enables and disables the component. When set True the component loads the associated RAS DLL's required to make the component methods and events available.  When not active using any of the components methods will generate a ERASDialNotActive Exception.


DomainName Property

property DomainName: string;

Description

The DomainName property specifies the NT domain on which authentication is to occur. A blank string "" specifies the Domain in which the Remote Access Server is a member.  The value asterisk ( * ) specifies the entry in the Phonebook entry set in the BookEntry property.


Password Property

property Password: string;

Description

The Password property is a string specifying the NT or LAN manager Password to authenticate the user's access to the Remote Access Server. This property is displayed as an asterisked string in the object inspector.

Comments

The UserId and Password properties only authenticate the user's access to the Remote Access Server and does not actually log the user onto the Network.

If both the UserId and Password properties are blank then the current logged in user and password are used for authentication.


PhoneBook Property

Property PhoneBook: string;

Description

The PhoneBook property is used to set the current phonebook for the component, it is this entry, used in conjuction with the BookEntry property, to use previously strored information in Remote Access set by using the RASPHONE.EXE application.


Userid Property

Property Userid: string;

Description

The Userid property is a string specifying the user's NT or LAN manager username to authenticate the user's access to the Remote Access Server.

Comments

The UserId and Password properties only authenticate the user's access to the Remote Access Server and does not actually log the user onto the Network.

If both the UserId and Password properties are blank then the current logged in user and password are used for authentication.


GetErrorDesc Method

function GetErrorDesc(Err: Longint): string;

Description

The GetErrorDesc method returns a descriptive text string for a supplied Remote Access Error returned by either the Dial or Hangup methods on the Error parameter in the event OnStateChanged calls.

Returns

A descriptive string of the error message or the string 'Not a RAS error';


InUse Method

function InUse: Boolean;

Description

The InUse method provides a simple test to see if the component is currently active in a RAS connection state.

Returns

True if a successful connection is in progress else False.


OnConnected Event

procedure OnConnected(Sender: TObject; Error: Longint);

Description

The OnConnected event is called when the current connection is at the RASCS_connection state. (See the ConnState Property).  If the passed Error parameter is none-zero then an error condition has occured and can be resolved using the GetErrorDesc method.


OnDisconnect Event

procedure OnDisconnect(Sender: Tobject; Error: Longint);

Description

The OnDisconnect event is called when the current connection is dropped or fails to connect and RASCS_disconnected state.is the current ConnState property value.  If the passed Error parameter is none-zero then an error condition has occured and can be resolved using the GetErrorDesc method.


OnStateChange Method

procedure OnStateChange(Sender: TObject; Error :Longint);

Description

The OnStateChange event is called when the current connection status changes. The connection status is specified by the ConnState property.  If the passed Error parameter is non-zero then an error condition has occured and can be resolved using the GetErrorDesc method.


ConnState Property

property ConnState: TRASConnState; (* readonly *);

Description

The ConnState Property contains the current state of the connection after the dial method has been used. The OnStateChanged and OnConnected and OnDisconnect events are fired when this property changes.


TRASConnState type

Description

The TRASconnState type can be one of the following dependant on the state of the current connection.

Values

RASCS_OpenPort

RASCS_PortOpened

RASCS_ConnectDevice

RASCS_DeviceConnected

RASCS_AllDevicesConnected

RASCS_Authenticate

RASCS_AuthNotify

RASCS_AuthCallBack

RASCS_AuthProject

RASCS_AuthLinkSpeed

RASCS_AuthAck

RASCS_ReAuthenticate

RASCS_Authenticated

RASCS_PrepareForCallBack

RASCS_WaitForModemReset

RASCS_WaitforCallBack

RASCS_Connected

RASCS_Disconnected


RASCS_OpenPort Value

RASCS_OpenPort

The communication port is about to be opened


RASCS_PortOpened

The communication port has been opened.


RASCS_ConnectDevice

A device is about to be connected.


RASCS_DeviceConnected

A device has been succesfully connected


RASCS_AllDevicesConnected

All devices in the device chain have been successfully

connected and a phyical link has been established


RASCS_Authenticate

The Authentication process is starting for validating

userid/password callback processing and linkspeed.


RASCS_AuthNotify

An Authentication event has occured. if Error is 0 then it

will be followed by one of the more specific authentication

states. If Error is Non-zero an error has occured


RASCS_AuthCallBack

The Remote Access Server has requested a callback number


RASCS_AuthProject

The projection phase is starting


RASCS_AuthLinkSpeed

The Link speed calculation phase is starting


RASCS_AuthAck

An authentication request is being acknowledged


RASCS_ReAuthenticate

Reauthentication (after callback) is starting


RASCS_Authenticated

The client has successfully completed authentication


RASCS_PrepareForCallBack

The line is about to disconnect in preperation for callback.


RASCS_WaitForModemReset

client is waiting in order to give modem time to reset itself


RASCS_WaitforCallBack

The client is waiting for an incoming call

from the Remote Access Server


RASCS_Connected

Successful connection and
genrates an OnConnected event


RASCS_Disconnected

Disconnection or a Connection failed and
generates an OnDisconnected Event


DeviceName Property

property DeviceName: string; (* read only *)

Description

The Device Name property is a readonly property and contains the type of the device used for the connection.  This value is set when the RASCS_ConnectDevice notification is generated.


DeviceType Property

property DeviceType: string; (* read only *)

Description

The Device Name property is a readonly property and continas the type of the device used for the connection.  This value is set when the RASCS_ConnectDevice notification is generated.


GetBookEntries Method

function GetBookEntriesMethod( Entries: TStringList; PhoneBook: string ): Integer;

Description

The GetBookEntries method returns all the phonebook entries into the TStringList for the passed phonebook parameter.  If phonebook is blank ( '' )  then the default phonebook is used.  This routine generates an ERASDialNotActive exception if the component is not active when this method is called.

Return Values

RAS_SUCCESS on successful completion and a non-zero value on error.


GetCurrentConnections Method

function GetCurrentConnections(connections: TStringList): Integer;

Description

The GetCurrentConnections returns a list of all the current connections into the passed TStringList.  If a phonebook entry has been used it returns the entry name otherwise if a phonenumber has been used it returns the number dialled.  This routine generates an ERASDialNotActive exception if the component is not active when this method is called.

Return Values

RAS_SUCCESS on success and a non-zero value on error.


GetDeviceInfo Method

function GetDeviceInfo(var DevName, Var DevType: string): integer;

Description

The GetDeviceInfo methods returns to the passed strings the DeviceName and DeviceType used in the current RAS session.  This information is only available after the RACS_ConnectDevice is generated by the OnStateChange notification event. You may never need to use this method as the componet fills the DeviceName and DeviceType properties when a RASCS_ConnectDevice is received.  This routine generates an ERASDialNotActive exception if the component is not active when this method is called.

Return Values

RAS_SUCCESS on successful completion or a Non-zero on value on error.


ERASDialNotActive Exception

type ERASDialNotActive = class( ERASDialError );

Description

The ERASDialNotActive exception is generated when any method is attempted to be used when the component is not active.


ERASDialError Execption
ERASDialError Exception

type ERASDialError = class ( Exception );

Description

The ERASDialError is the base exception class for all RASdial errors this can be used to trap all specific RASDial exception events

Example

procedure dialout;

begin

try

RasDial1.Dial

except

on e: ERASDialError do

messageDlg( e.Message, mtInformation, [mbOK] , 0);

end;

end;